import Buff from '@/Buff';
import BuffUtil from '@/BuffUtil';
import BuffCommon from 'code/Core/Common/BuffCommon';
import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/* 回春术 */
export default class DLY_Rejuvination extends AbilityBase {
    buffInterval(buff: Buff) {
        this.heal(buff.getParent(), buff.getCaster());
    }
    buffType: AppBuffType = {
        id: 'buff_DLY_Rejuvination',
        art: this.art,
        name: this.abilityName,
        ubertip: '受到治疗，持续回复生命',
        dur: 12,
        interval: 1,
        onInterval: this.buffInterval.bind(this),
        targetArt: 'Abilities\\Spells\\NightElf\\Rejuvenation\\RejuvenationTarget.mdl',
        targetAttach: 'origin',
    };
    static instance: DLY_Rejuvination;
    constructor(id: string) {
        super(id);
        DLY_Rejuvination.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        // BuffUtil.addBuff(target, this.buffType.id, source);
        BuffCommon.addBuff({
            target,
            caster: source,
            ablityId: this.id,
            buffTypeId: this.buffType.id,
        });
        this.heal(target, source);
    }
    heal(target: unit, source: unit) {
        let lv = this.getAbilityLevel(source);
        let dmg = 18 * lv + UnitCommon.取法强(source) * (0.6 + 0.5 * lv);
        DamageSystemInstance.applyDotHeal(target, source, dmg, this.id);
    }
}
